{template 'header', 'mobile'}
<style type="text/css">
.slide {width:100%;height:100px;background:#FAFAFA;overflow:hidden;}
.quick {height:70px;background:#FFFFFF;text-align:center;padding:15px 0;}
.quick li {width:25%;float:left;}
.quick img {width:46px;margin:0 0 6px 0;}
.quick span {display:block;font-size:12px;}
.quick em {font-style:normal;font-size:12px;color:#FFFFFF;z-index:8;position:relative;display:block;width:22px;height:22px;line-height:22px;left:50%;margin:-74px 0 0 8px;background:#FF0000;border-radius:50%;text-align:center;}
.channel {background:#FFFFFF url('static/img/bg-channel.png') repeat-x 0 bottom;height:44px;overflow-x:auto;margin-top:10px;font-size:16px;}
.channel ul {width:10000px;}
.channel li {height:42px;line-height:42px;padding:0 10px;border-bottom:#EFEFF4 2px solid;float:left;}
.channel .on {border-bottom:#007AFF 2px solid;color:#007AFF;}
.channel_fix {position:fixed;z-index:9;left:0;top:{if $DT_MOB[browser]=='b2b'&&$DT_MOB[os]=='ios'}58{else}38{/if}px;right:0;border-top:#A7A7AA 0.5px solid;}
#main {background:#FFFFFF;}
.spin-more,.spin-load {height:44px;background:#FFFFFF url('static/img/spinner.gif') no-repeat center center;background-size:16px 16px;display:none;}
.home-search {text-align:center;padding:10px;}
.home-search div {height:28px;line-height:28px;background:#FFFFFF;border-radius:4px;}
.home-search img {width:16px;height:16px;vertical-align:top;padding-top:6px;padding-right:8px;}
.home-search span {color:#8E8E93;font-size:14px;font-weight:normal;}
.home-goto {background:#FFFFFF;padding:8px 8px 16px 8px;text-align:center;display:none;}
.home-goto div {background:#007AFF;padding:8px;border-radius:4px;font-size:16px;color:#FFFFFF;}
.list-txt {border-top:none;}
</style>
<div id="head-bar">
<div class="head-bar">
{if $DT_MOB[browser]=='b2b'}
<div class="head-bar-back" onclick="api.execScript({name:'root',script:'Dexec({$_userid});'});api.closeWin({name:'destoon'});api.closeFrame({name:'destoon'});">
<img src="static/img/icon-back.png" width="24" height="24"/><span>返回</span>
</div>
{else}
<div class="head-bar-left">
<a href="channel.php"><img src="static/img/icon-sort.png" width="24" height="24"/></a>
</div>
{/if}
<div class="head-bar-title">{$head_name}</div>
<div class="head-bar-right">
<a href="setting.php"><img src="static/img/icon-setting.png" width="24" height="24"/></a>
</div>
</div>
<div class="head-bar-fix"></div>
</div>
{if $ads}
<div id="mobile-slide" class="slide">
{loop $ads $t}
<a href="{$t[url]}" target="_blank" rel="external"><img src="{$t[image_src]}" alt="" style="width:100%;"/></a>
{/loop}
</div>
{/if}
<div class="home-search">
	<div><a href="search.php"><img src="static/img/ico-search.png"/><span>输入关键词搜索</span></a></div>
</div>
<div class="quick">
	<ul>
		<li><a href="my.php"><img src="static/img/home-member.png" width="46" height="46"/><span>会员中心</span></a></li>
		<li><a href="my.php?action=info"><img src="static/img/home-post.png" width="46" height="46"/><span>发布信息</span></a></li>
		<li><a href="my.php?action=trade"><img src="static/img/home-order.png" width="46" height="46"/><span>订单中心</span></a></li>
		{if isset($MODULE[16])}
		<li><a href="cart.php"><img src="static/img/home-cart.png" width="46" height="46"/><span>购物车</span></a>{if $_cart}<em>{if $_cart>99}99{else}{$_cart}{/if}</em>{/if}</li>
		{else}
		<li><a href="message.php"><img src="static/img/home-message.png" width="46" height="46"/><span>站内信</span></a>{if $_message}<em>{if $_message>99}99{else}{$_message}{/if}</em>{/if}</li>
		{/if}
	</ul>
</div>
<div id="segment"></div>
<div class="channel" id="channel">
	<ul>
	{loop $MOD_MY $i $m}
	<li{if $i==0} class="on"{/if} id="m_{$m[moduleid]}" onclick="Dmenu({$m[moduleid]});">{$m[name]}</li>
	{/loop}
	</ul>
</div>
<div class="spin-load" onclick="window.location.reload();"></div>
<div id="main">
</div>
<div class="spin-more" onclick="window.location.reload();"></div>
<div class="home-goto"><a href="channel.php"><div>进入频道</div></a></div>
<script type="text/javascript">
var C = {$MOD_MY[0][moduleid]};
var P = 1;
function Dmenu(i) {
	if(i == C) return;
	$('.spin-more').show();
	$('.spin-load').show();
	$('.home-goto').hide();	
	$('#m_'+C).removeClass('on');
	C = i;
	$('#m_'+C).addClass('on');
	P = 1;
	$('html, body').animate({scrollTop:$('#segment').offset().top-{if $DT_MOB[browser]=='b2b'&&$DT_MOB[os]=='ios'}108{else}88{/if}}, 500);
	$('#channel').addClass('channel_fix');
	Dload();
}
function Dstop() {
	$('.spin-more').hide();
	$('.spin-load').hide();
	$('.home-goto a').attr('href', 'index.php?moduleid='+C);
	$('.home-goto div').html('进入'+$('#m_'+C).html()+'频道');
	$('.home-goto').show('slow');
}
function Dload() {
	if(P > 3) {
		Dstop();
		return;
	}
	$.get('index.php?action=ajax&moduleid='+C+'&page='+P, function(result){
		$('.spin-load').hide();
		if(result && result.indexOf('list-empty') == -1) {
			P == 1 ?  $('#main').html(result) : $('#main').append(result);
		} else {
			if(P == 1) $('#main').html('<br/><br/><center>暂无信息</center><br/><br/>');
			P = 4;
			Dstop();
		}
	});	
}
{if $ads}
function dslide(id, time) {
	if($('#'+id).html().indexOf('<ul') != -1) return;
	var _this = this;
	this.w = $(document).width();
	this.h = $('#'+id).height();
	this.c = 0;
	this.src = [];
	this.url = [];
	this.alt = [];
	this.tar = [];
	$('#'+id).find('a').each(function(i) {
		_this.src.push($(this).find('img')[0].src);
		_this.alt.push($(this).find('img')[0].alt);
		_this.url.push(this.href);
		_this.tar.push(this.target);
	});
	if(!this.src[0]) return;
	this.max = this.src.length;
	this.htm = '<ul id="'+id+'_ul" style="position:relative;width:'+this.w*(this.max+1)+'px;height:'+this.h+'px;z-index:1;overflow:hidden;">';
	for(var i = 0; i < this.max; i++) {
		this.htm += '<li style="float:left;"><a href="'+this.url[i]+'" target="'+this.tar[i]+'"><img src="'+this.src[i]+'" width="'+this.w+'"/></a></li>';
	}
	this.htm += '</ul><div style="clear:both;"></div>';
	if(this.alt[0]) this.htm += '<div style="width:'+this.w+'px;height:24px;line-height:24px;overflow:hidden;z-index:2;position:relative;top:-24px;background:#384349;filter:Alpha(Opacity=80);opacity:0.8;">&nbsp;</div>';
	if(this.alt[0]) this.htm += '<div id="'+id+'_alt" style="width:'+(this.w-12)+'px;height:24px;line-height:24px;overflow:hidden;z-index:3;position:relative;top:-48px;padding:0 6px 0 6px;font-weight:bold;color:#FFFFFF;">'+this.alt[0]+'</div>';
	this.htm += '<div style="width:'+this.w+'px;height:20px;overflow:hidden;z-index:4;position:relative;top:-'+(this.alt[0] ? 68 : 30)+'px;text-align:center;padding-left:6px;">';
	for(var i = 0; i < this.max; i++) {
		this.htm += '<span id="'+id+'_no_'+i+'" style="display:inline-block;width:6px;height:6px;border:1px solid #FFFFFF;border-radius:6px;margin-right:6px;'+(i == this.c ? 'background:#007AFF;' : 'background:#FFFFFF;')+'"></span>';
	}
	this.htm += '</div>';
	$('#'+id).html(this.htm);
	if(this.max == 1) return;
	this.t;
	this.p = 0;
	$('#'+id).mouseover(function() {_this.p=1;});
	$('#'+id).mouseout(function() {_this.p=0;});
	$('#'+id).find('span').each(function(i) {
		$(this).mouseover(function() {
			_this.slide(i);
		});
	});
	this.slide = function(o) {
		if(o == this.c) return;
		if(o < 0 || o >= this.max) return;
		if(o == 0 && this.c == this.max - 1) {
			$('#'+id+'_ul').append($('#'+id+'_ul li:first').clone());
			$('#'+id+'_ul').animate({'left':-this.w*this.max},500,function() {
				$('#'+id+'_ul').css('left','0');
				$('#'+id+'_ul li:last').remove();
			});
		} else {
			$('#'+id+'_ul').animate({'left':-o*this.w},500);
		}
		$('#'+id+'_no_'+this.c).css('background','#FFFFFF');
		$('#'+id+'_no_'+o).css('background','#007AFF');
		if(this.alt[0]) $('#'+id+'_alt').html(this.alt[o]);
		this.c = o;
	}
	this.start = function() {
		if(this.p) return;
		if(this.c == this.max - 1) {
			this.slide(0);
		} else {
			this.slide(this.c+1);
		}
	}
	if(!time) time = 5000;
	this.t = setInterval(function() {_this.start();}, time);
	return true;
}
{/if}
$(document).on('pageinit', function(event) {
//$(document).ready(function() {
	$('.spin-more').show();
	Dload();
	$('#main').on('scrollstop',function(event){
		var cmh2 = $(window).height();
		var cmh1 = $('.spin-more').offset().top;
		if($(document).scrollTop() + cmh2 >= cmh1-100) {
			P++;
			Dload();
		}
		//if($(document).scrollTop() > T-44) {	
		if($(document).scrollTop() > $('#segment').offset().top) {	
			$('#channel').addClass('channel_fix');
		} else {
			$('#channel').removeClass('channel_fix');
		}
	});
{if $ads}	
	var ds = new dslide('mobile-slide');
	if(ds) {
		$('#mobile-slide').on('swipeleft',function(){
			ds.slide(ds.c+1);
		});
		$('#mobile-slide').on('swiperight',function(){
			ds.slide(ds.c-1);
		});
		$(window).bind('orientationchange.slide', function(e){
			ds.w = $(document).width();
			$('#mobile-slide').find('ul').css('width', ds.w*(ds.max+1));
			$('#mobile-slide').find('img').css('width', ds.w);
			$('#mobile-slide').find('div').css('width', ds.w);
		});
	}
{/if}
});
</script>
{template 'footer', 'mobile'}